package 通信;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class sever {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(9090);

        System.out.println("服务端启动");

        Socket accept = serverSocket.accept();
        System.out.println(accept.getInetAddress()+"服务端连接成功");

        InputStream inputStream = accept.getInputStream();

        byte[] buf = new byte[1024];
        int len = inputStream.read(buf);

        System.out.println(new String(buf,0,len));

        OutputStream outputStream = accept.getOutputStream();
        outputStream.write("你的信息我收到了".getBytes());

        outputStream.close();
        inputStream.close();
        accept.close();
    }
}
